// pages/mine/mine.js
const app = getApp()
Page({

 
  /**
   * 页面的初始数据
   */
  data: {
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    daifukuan: false
  },

  //选团长点击
  xtzhClk(){
    wx.navigateTo({
      url:'../mineS/xuanduanzh/xuanduanzh'
    })
  },
  //推荐有奖点击
  recommendClk() {
    wx.navigateTo({
      url: '../mineS/recommend/recommend'
    })
  },
  //设置点击
  setClk() {
    wx.navigateTo({
      url: '../mineS/set/set'
    })
  },
  //收货地址点击
  siteClk() {
    wx.navigateTo({
      url: '../mineS/site/site'
    })
  },

 

  //售后点击
  shhClk() {
    var that = this;
    var abc = JSON.stringify({
      daifukuan: true,
      daifahuo: true,
      daishouhuo: true,
      shouhous: false,
      all: true
    });
    wx.navigateTo({
      url: '../mineS/dingdan/dingdan?data=' + abc
    })
  },
  //待收货点击
  dshhClk() {
    var that = this;
    var abc = JSON.stringify({
      daifukuan: true,
      daifahuo: true,
      daishouhuo: false,
      shouhous: true,
      all: true
    });
    wx.navigateTo({
      url: '../mineS/dingdan/dingdan?data=' + abc
    })
  },
  //待发货点击
  dfhClk() {
    var that = this;
    var abc = JSON.stringify({
      daifukuan: true,
      daifahuo: false,
      daishouhuo: true,
      shouhous: true,
      all: true
    });
    wx.navigateTo({
      url: '../mineS/dingdan/dingdan?data=' + abc
    })
  },
  //待付款点击
  dfkClk() {
    var that = this;
    var abc = JSON.stringify({
      daifukuan: false,
      daifahuo: true,
      daishouhuo: true,
      shouhous: true,
      all: true
    });
    wx.navigateTo({
      url: '../mineS/dingdan/dingdan?data=' + abc
    })
  },
  //我的订单点击
  dingdanClk() {
    var that = this;
    var abc = JSON.stringify({
      daifukuan: true,
      daifahuo: true,
      daishouhuo: true,
      shouhous: true,
      all: false
    });
    wx.navigateTo({
      url: '../mineS/dingdan/dingdan?data=' + abc
    })
  },

  //积分点击
  jifenClk() {
    wx.showLoading({
      title: '加载中...',
    })
    wx.navigateTo({
      url: '../mineS/jifen/jifen',
    })
    wx.hideLoading()
  },

  //优惠卷点击
  youhjClk() {
    wx.showLoading({
      title: '加载中...',
    })
    wx.navigateTo({
      url: '../mineS/youhuijian/youhuijian',
    })
    wx.hideLoading()
  },

  //余额点击
  balanceClk() {
    wx.showLoading({
      title: '加载中...',
    })
    wx.navigateTo({
      url: '../mineS/balance/balance',
    })
    wx.hideLoading()
  },


  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function() {
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else if (this.data.canIUse) {
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },




  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})